//-------------------------------------------------------------------------------------------------------------

#include "includes.h"
#include "function.h"
//-------------------------------------------------------------------------------------------------------------

Function::Function( const TCHAR* name) 
:	mFuncName( name), 
	mTotalTime(0.0), 
	mNumCalls(0), 
	mChildTime(0.0),
	mStartTime(0)
{
}
//-------------------------------------------------------------------------------------------------------------

void Function::addChildTime( float time)
{
	mChildTime += time;
}
//-------------------------------------------------------------------------------------------------------------

void Function::addTime( float time)
{
	mNumCalls++;
	mTotalTime += time;
}
//-------------------------------------------------------------------------------------------------------------

float Function::getTotalTime() const
{
	return mTotalTime;
}
//-------------------------------------------------------------------------------------------------------------

float Function::getChildTime() const
{
	return mChildTime;
}
//-------------------------------------------------------------------------------------------------------------

const TCHAR* Function::getName() const
{
	return mFuncName.c_str();
}
//-------------------------------------------------------------------------------------------------------------

int	 Function::getCalls() const
{
	return mNumCalls;
}
//-------------------------------------------------------------------------------------------------------------

void Function::startTimer()
{
	mStartTime = clock();
}
//-------------------------------------------------------------------------------------------------------------

void Function::stopTimer( float &time)
{
	clock_t currTime = clock();
	time = (float) ( currTime - mStartTime) / CLOCKS_PER_SEC;
	mStartTime = 0;
}
//-------------------------------------------------------------------------------------------------------------